package com.liuzh.deviceinfo.appinfo;

import android.os.Bundle;
import android.os.Handler;
import android.text.TextUtils;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.webkit.WebView;
import android.widget.FrameLayout.LayoutParams;
import android.widget.ProgressBar;
import android.widget.Toast;
import b.b.c.f;
import c.h.a.b0.m;
import c.h.a.m0.h;
import c.h.a.m0.n;
import c.h.a.x.i;
import c.h.a.x.j;
import c.h.a.x.k;
import c.h.a.x.o;
import c.h.a.x.r;
import com.liuzh.deviceinfo.base.BaseActivity;
import java.io.File;
import java.util.concurrent.RejectedExecutionException;

public class ManifestActivity extends BaseActivity {
    public static final /* synthetic */ int v = 0;
    public WebView q;
    public ProgressBar r;
    public String s;
    public String t;
    public boolean u = false;

    public class a implements n {
        public final /* synthetic */ m a;

        public a(m mVar) {
            this.a = mVar;
        }

        public void a() {
            if (!ManifestActivity.this.u) {
                this.a.m0(false, false);
                Toast.makeText(ManifestActivity.this, 2131689838, 0).show();
            }
        }

        public void onSuccess() {
            if (!h.q(ManifestActivity.this) && !ManifestActivity.this.u) {
                this.a.m0(false, false);
                String path = new File(r.b, ManifestActivity.this.t).getPath();
                b.b.c.f.a aVar = new b.b.c.f.a(ManifestActivity.this);
                aVar.e(2131690257);
                aVar.a.f = ManifestActivity.this.getString(2131689965, new Object[]{path});
                aVar.d(17039370, null);
                aVar.c(2131690352, null);
                aVar.b(17039361, null);
                f g = aVar.g();
                g.c(-2).setOnClickListener(new i(this, path));
                g.c(-3).setOnClickListener(new j(this, path));
                g.setCanceledOnTouchOutside(false);
            }
        }
    }

    public final void A() {
        if (!TextUtils.isEmpty(this.s)) {
            m q0 = m.q0(this);
            String str = this.s;
            String str2 = this.t;
            a aVar = new a(q0);
            File file = r.a;
            c.h.a.m0.p.a.a(new o(str, str2, aVar));
        }
    }

    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        String stringExtra = getIntent().getStringExtra("pkg");
        this.t = getIntent().getStringExtra("fileName");
        if (TextUtils.isEmpty(stringExtra)) {
            finish();
            return;
        }
        z();
        try {
            View webView = new WebView(this);
            this.q = webView;
            setContentView(webView);
            this.q.setBackgroundColor(c.f.a.a.a.a.n(this, 16842801));
            ProgressBar progressBar = new ProgressBar(this);
            this.r = progressBar;
            addContentView(progressBar, new LayoutParams(-2, -2, 17));
            k kVar = new k(this, stringExtra);
            Handler handler = c.h.a.m0.p.a.a;
            try {
                c.h.a.m0.p.a.c.execute(kVar);
            } catch (RejectedExecutionException unused) {
            }
        } catch (Exception unused2) {
            finish();
        }
    }

    public boolean onCreateOptionsMenu(Menu menu) {
        if (!TextUtils.isEmpty(this.t)) {
            menu.add(0, 1, 0, 2131690254).setShowAsActionFlags(2).setIcon(2131231056);
        }
        return super.onCreateOptionsMenu(menu);
    }

    public void onDestroy() {
        super.onDestroy();
        WebView webView = this.q;
        if (webView != null) {
            webView.destroy();
        }
    }

    public boolean onOptionsItemSelected(MenuItem menuItem) {
        int itemId = menuItem.getItemId();
        if (itemId == 16908332) {
            finish();
            return true;
        } else if (itemId != 1) {
            return super.onOptionsItemSelected(menuItem);
        } else {
            String str = "android.permission.WRITE_EXTERNAL_STORAGE";
            if (c.h.a.e0.a.b(this, str)) {
                A();
            } else {
                b.i.b.a.c(this, new String[]{str}, 34);
            }
            return true;
        }
    }

    public void onRequestPermissionsResult(int i, String[] strArr, int[] iArr) {
        super.onRequestPermissionsResult(i, strArr, iArr);
        if (c.h.a.e0.a.f(iArr)) {
            if (i == 34) {
                A();
            }
        } else if (i == 34 && !c.h.a.e0.a.c(this, "android.permission.WRITE_EXTERNAL_STORAGE")) {
            int i2 = c.h.a.b0.o.i0;
            c.h.a.b0.o.r0(o(), 2131690076, 2131690255);
        }
    }

    public void onSaveInstanceState(Bundle bundle) {
        super.onSaveInstanceState(bundle);
        this.u = true;
    }
}
